﻿using System.ComponentModel.DataAnnotations;
using FinancePortal.Domain.Model;

namespace FinancePortal.Web.Models
{
    public class ActivityViewModel
    {
        public int Id { get; set; }

        [Required]
        [StringLength(50)]
        public string Name { get; set; }

        [Required]
        [StringLength(500)]
        public string Description { get; set; }

        [Required]
        public int AreaId { get; set; }

        public int ParentId { get; set; }

        public static Activity ToModel(ActivityViewModel view)
        {
            return new Activity
            {
                Id = view.Id,
                Name = view.Name,
                Description = view.Description,
                AreaId = view.AreaId,
                ParentActivityId = (view.ParentId == 0 ? null : (int?)view.ParentId)
            };
        }
    }
}